package com.ruoyi.yl.utils;


import com.ruoyi.common.core.utils.SpringUtils;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.yl.domain.Users;
import com.ruoyi.yl.service.impl.UsersServiceImpl;

public class LoginUserUtil {

    public  static void refreshUsers(){
        //刷新缓存Users
        UsersServiceImpl usersService = SpringUtils.getBean(UsersServiceImpl.class);
        String openid = SecurityUtils.getLoginUser().getUsers().getOpenid();
        Users newUsers = usersService.selectByOpenId(openid);
        SecurityUtils.getLoginUser().setUsers(newUsers.getWxUser());
        //刷新Redis
        TokenService tokenService = SpringUtils.getBean(TokenService.class);
        tokenService.refreshToken(SecurityUtils.getLoginUser());
    }
}
